package com.woniuxy.intellihome.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniuxy.intellihome.entity.SpecDetail;
import com.woniuxy.intellihome.mapper.SpecDetailMapper;
import com.woniuxy.intellihome.service.SpecDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hw 实现了根据spec id查询spec detaillist 08-14 12：00
 * @since 2021-08-11
 */
@Service
public class SpecDetailServiceImpl extends ServiceImpl<SpecDetailMapper, SpecDetail> implements SpecDetailService {

    @Autowired
    private SpecDetailService specDetailService;
    @Autowired
    private SpecDetailMapper detailMapper;


    @Override
    public List<SpecDetail> getBySpecId(int id) {
        SpecDetail specDetail=new SpecDetail();
        specDetail.setSpecId(id);
        QueryWrapper<SpecDetail> wrapper=new QueryWrapper<>(specDetail);
        List<SpecDetail> detailList = specDetailService.list(wrapper);
        return detailList;
    }

    /**
     * 得到属于sku的details
     * @param skuId spec的id
     */
    @Override
    public List<SpecDetail> getDetailsBelong2Sku(int skuId) {
        List<SpecDetail> details = detailMapper.getDetailBelong2Sku(skuId);

        return details;
    }
}
